// 时间戳转换成日期
const timeFilter = (value, format) => {
  let date = new Date(value)
  let y = date.getFullYear()
  let MM = date.getMonth() + 1
  MM = MM < 10 ? ('0' + MM) : MM
  let d = date.getDate()
  d = d < 10 ? ('0' + d) : d
  let h = date.getHours()
  h = h < 10 ? ('0' + h) : h
  let m = date.getMinutes()
  m = m < 10 ? ('0' + m) : m
  let s = date.getSeconds()
  s = s < 10 ? ('0' + s) : s
  //   return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
  switch (format) {
    case 'MM-DD zh-cn':
      return `${MM}月${d}日`
    case 'YY-MM-DD':
      return `${y}-${MM}-${d}`
    case '年月日':
      return {
        y: `${y}`,
        m: `${MM}`,
        d: `${d}` }
      // `${Y}年${M}月${D}日`

    case 'MM-DD':
      return `${MM}-${d}`
    case 'hh:mm':
      return `${h}:${m}`
    case 'hh:mm:ss':
      return `${h}:${m}:${s}`
    case 'YY-MM-DD hh:mm:ss':
      return `${y}-${MM}-${d} ${h}:${m}:${s}`
    case 'YY-MM-DD hh:mm':
      return `${y}-${MM}-${d} ${h}:${m}`
    case 'MM-DD hh:mm':
      return `${MM}-${d} ${h}:${m}`
    default:
      return `${y}-${MM}-${d}`
  }
}
export { timeFilter }
